import { ref } from "vue"
import { defineStore } from "pinia"
import { AlgoTypeEnum, QuickStartProcessEnum, TabTypeEnum } from "@/constants/other-keys"

export interface QuickStartItem {
  gcId: string | undefined
  gameId: string | undefined
  taskId: string | undefined
}

const PROCESS_DEFAULT_VALUE = {
  RL: {
    train: {
      gcId: undefined,
      gameId: undefined,
      taskId: undefined
    },
    eval: {
      gcId: undefined,
      gameId: undefined,
      taskId: undefined
    }
  },
  ML: {
    train: {
      gcId: undefined,
      gameId: undefined,
      taskId: undefined
    },
    eval: {
      gcId: undefined,
      gameId: undefined,
      taskId: undefined
    }
  }
}

export const useQuickStartStore = defineStore("quick-start", () => {
  // 业务类型
  const serviceType = ref<AlgoTypeEnum | null>(null)
  // 博弈 检测
  const modeType = ref<TabTypeEnum>(TabTypeEnum.DYNAMIC)
  // 当前过程 默认训练场景选择
  const process = ref<QuickStartProcessEnum>(QuickStartProcessEnum.TrainBY)

  const processData = ref<{
    [propName: string]: {
      train: QuickStartItem
      eval: QuickStartItem
    }
  }>(PROCESS_DEFAULT_VALUE)

  //#region
  const setServiceType = (param: AlgoTypeEnum) => {
    serviceType.value = param
    modeType.value = param == AlgoTypeEnum.RL ? TabTypeEnum.DYNAMIC : TabTypeEnum.STATIC
  }
  const getServiceType = () => {
    return serviceType.value
  }
  //#endregion

  const clearData = () => {
    serviceType.value = null
    process.value = QuickStartProcessEnum.TrainBY
    processData.value = PROCESS_DEFAULT_VALUE
  }

  return {
    modeType,
    process,
    processData,
    setServiceType,
    getServiceType,
    clearData
  }
})
